
/**
 * 设置全局的分页
 */
var page_ = new page({search:search});

/**
 * 定义容器全局变量
 */
var con = new container({
	datagrid:'#datagrid',
	datagridtoolbar:'#datagrid-toolbar', 
	singleSelect:true});

$(document).ready(function(){

	$('#datagrid-toolbar #search_link').linkbutton({
	    onClick:function(){
	    	search(page_);
	    }
	});
	
	/**
	 * 绑定重置事件
	 */
	$('#datagrid-toolbar #reset_link').linkbutton({
		onClick:function(){
			 $("#organName").textbox("setValue","");
			 $("#module").textbox("setValue","");
			 $("#operation").textbox("setValue","");
			 $("#createName").textbox("setValue","");
			 $("#startDate").datebox("setValue","");
			 $("#endDate").datebox("setValue","");
		}
	});
	
	search(page_);
});


/**
 * 查询
 * @param page
 */
function search(pg){
	var url = ctx + "/logs/query";
	page_.pageSize = pg.pageSize;
	page_.pageNumber = pg.pageNumber;
	query(url, getCondition(), con, page_);
}


/**
 * 获取查询条件
 * @returns {condition}
 */
function getCondition(){
	var condition = {};
	condition.organCode = $('#organCode').val();
	condition.organName = $('#logsform #organName').textbox('getValue');
	condition.module = $('#logsform #module').textbox('getValue');
	condition.operation = $('#logsform #operation').textbox('getValue');
	condition.createName = $('#logsform #createName').textbox('getValue');
	condition.startDate = $('#logsform #startDate').datebox('getValue');
	condition.endDate = $('#logsform #endDate').datebox('getValue');
	if($.trim(condition.startDate).length != 0){
		condition.startDate = condition.startDate + " 00:00:00";
	}
	if($.trim(condition.endDate).length != 0){
		condition.endDate = condition.endDate + " 23:59:59";
	}
	return condition;
}